package com.chz.SupermarketMS.service;

import com.chz.SupermarketMS.dao.InventoryRepository;
import com.chz.SupermarketMS.entities.Inventory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InventoryService {

    @Autowired
    InventoryRepository inventoryRepository;

    public Inventory save(Inventory inventory){
        return inventoryRepository.save(inventory);
    }

    public List<Inventory> getAll(){
        return inventoryRepository.findAll();
    }

//    public Inventory findByCommodityId(long theId) {
//        return inventoryRepository.findByInventoryId(theId);
//    }

    public Inventory findByInventoryId(long theId) {
        return inventoryRepository.findByInventoryId(theId);
    }

    public void delete(Inventory theInventory) {
        inventoryRepository.delete(theInventory);
    }
}
